package com.unidbg.text;

import com.unidbg.bean.Result;
import com.unidbg.util.TestJni;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

@RestController
public class TextController {
    private Result result = new Result();
    @RequestMapping("/")
    public Result index(){
        try {
            result.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
            result.setData(TestJni.main1(new String[]{"phone=Gg6Ye4yoRtrWiaVmUjdBxA==1626360428651phone_code=86sms_code=123456", "1626360428687"}));
        } catch (IOException e) {
            e.printStackTrace();
            result.setData("加密错误");
        }
        return result;
    }
    @RequestMapping("s")
    public Result sing(){
        try {
            result.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
            String so = "C:\\Users\\Erin\\Desktop\\libtalaccsecurity.so";
            String obj= "com/tal/user/fusion/util/JNISecurity";
            String funname= "sign(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;";

            result.setData(TestJni.main2(so,obj,funname,"phone=Gg6Ye4yoRtrWiaVmUjdBxA==1626360428651phone_code=86sms_code=123456","1626360428687"));
        } catch (IOException e) {
            e.printStackTrace();
            result.setData("加密错误");
        }
        return result;
    }

}
